;;; ~/.doom.d/Hesperus-UI.el -*- lexical-binding: t; -*-

;; maximize frame when init
(toggle-frame-maximized)

;; globally disable line numbers when init via:
;; github.com/hlissner/doom-emacs/issues/870
(setq display-line-numbers-type nil)


;; awesome-tab
(require 'init-awesome-tab)
;; Colorize color-names in buffers
(require 'init-rainbow-mode)


(setq doom-theme 'monokai)

(after! monokai-theme
  (set-face-attribute 'default nil :foreground "#3de1ad") ;; Emerald #7bcfa6 stone-Cyan #7fecad Ethereal
  (set-face-attribute 'font-lock-builtin-face nil :foreground "#ffc773") ;; turmeric
  (set-face-attribute 'font-lock-comment-face nil :slant 'italic :foreground "#bbcdc5") ;; crab-shell
  (set-face-attribute 'font-lock-comment-delimiter-face nil :foreground "#80766e") ;; Wild-goose
  (set-face-attribute 'font-lock-constant-face nil :foreground "#f47759") ;; city-wall-brick
  (set-face-attribute 'font-lock-doc-face nil :italic t :foreground "#f9906f") ;; Intoxicated-face
  (set-face-attribute 'font-lock-function-name-face nil :weight 'bold :foreground "#ffa631") ;; apricot
  (set-face-attribute 'font-lock-keyword-face nil :slant 'italic :foreground "#8dd4e8") ;; Azure
  ;; (set-face-attribute 'font-lock-string-face nil :foreground "#e9f1f6" :background "#35363a") ;; frost,
  (set-face-attribute 'font-lock-string-face nil :foreground "#e9f1f6" :background "#392f41") ;; frost, crow-Black
  )

;; (set-face-attribute 'default nil :foreground "#065279") ;; Indigo
;; (set-face-attribute 'font-lock-builtin-face nil :foreground "#60281e") ;; chestnut
;; (set-face-attribute 'font-lock-comment-face nil :foreground "#9b4400") ;; Brown-Red
;; (set-face-attribute 'font-lock-constant-face nil :foreground "#424c50") ;; Raven-Cyan
;; (set-face-attribute 'font-lock-doc-face nil :foreground "#9c5333") ;; ocher
;; (set-face-attribute 'font-lock-keyword-face nil :foreground "#4b5cc4") ;; Royal-Blue
;; (set-face-attribute 'font-lock-string-face nil :foreground "#057748" :background "#e0eee8") ;; pine-Green, duck-egg


;; split window right/below
;; via emacs-china.org/t/topic/945/2
(defun Hesperus-split-window-right ()
  "Split window with another buffer."
  (interactive)
  (select-window (split-window-right))
  (switch-to-buffer (other-buffer)))

(defun Hesperus-split-window-below ()
  "Split window with another buffer."
  (interactive)
  (select-window (split-window-below))
  (switch-to-buffer (other-buffer)))

(bind-key* "C-x 3" #'Hesperus-split-window-right)
(bind-key* "C-x 2" #'Hesperus-split-window-below)

;; @zsxh AT emacs-china
;; (if (display-graphic-p)
;;     (progn
;;       (set-frame-font "SF Mono-13.5:weight=semi-bold" nil t)
;;       (dolist (charset '(kana han symbol cjk-misc bopomofo))
;;         (set-fontset-font (frame-parameter nil 'font)
;;                           charset (font-spec :family "Source Han Serif"))
;;         (setq face-font-rescale-alist '(("Source Han Serif" . 1.24))))))

;; blog.csdn.net/xh_acmagic/article/details/78939246
(defun Hesperus-better-font ()
  (interactive)
  ;; english font
  (if (display-graphic-p)
      (progn
        (set-face-attribute 'default nil :font (format "%s:pixelsize=%d" "Source Code Pro" 14)) ;; 11 13 17 19 23
        ;; chinese font, same to chinese-fonts-setup, cnfonts
        (dolist (charset '(kana han symbol cjk-misc bopomofo))
          (set-fontset-font (frame-parameter nil 'font)
                            charset
                            (font-spec :family "Source Han Sans CN" :size 16)))) ;; 14 16 20 22 28
    ))

(defun Hesperus-init-font (frame)
  (with-selected-frame frame
    (if (display-graphic-p)
        (Hesperus-better-font))))

(if (and (fboundp 'daemonp) (daemonp))
    (add-hook 'after-make-frame-functions #'Hesperus-init-font)
  (Hesperus-better-font))


(provide 'Hesperus-UI)
;;; Hesperus-UI.el ends here
